<%--
  Created by IntelliJ IDEA.
  User: caojian
  Date: 2017/3/10
  Time: 下午5:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>修改密码</title>
    <jsp:include page="common/common_css.jsp"/>
</head>
<body>
<jsp:include page="common/header.jsp"/>
<div class="ui main container">
    <div class="ui middle aligned center aligned grid">
        <div class="column">
            <h2 class="ui teal header">
                <div class="content">
                    修改密码
                </div>
            </h2>
            <jsp:include page="common/message.jsp"/>
            <form class="ui large form" method="post" action="${pageContext.request.contextPath}/sale/own/modifyPsd">
                <div class="ui stacked segment">
                    <div class="field">
                        <div class="ui labeled input">
                            <div class="ui label">
                                邮箱：
                            </div>
                            <input disabled name="email" type="text" value="<security:authentication property="name"/>"
                                   maxlength="30">
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui labeled input">
                            <div class="ui label">
                                旧密码：
                            </div>
                            <input name="oldPassword" type="password" maxlength="30">
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui labeled input">
                            <div class="ui label">
                                新密码：
                            </div>
                            <input name="newPassword" type="password" maxlength="30">
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui labeled input">
                            <div class="ui label">
                                确认密码：
                            </div>
                            <input name="confirmPassword" type="password" maxlength="30">
                        </div>
                    </div>
                    <button class="ui fluid large teal submit button">完成修改</button>
                    <div id="JS-error-message" class="ui error message"></div>
                </div>
            </form>
        </div>
    </div>
</div>

<jsp:include page="common/footer.jsp"/>
<jsp:include page="common/common_js.jsp"/>
<script>
    $(function () {
        $('.ui.form')
            .form({
                fields: {
                    oldPassword: {
                        identifier: 'oldPassword',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入旧密码。'
                            },
                            {
                                type: 'length[6]',
                                prompt: '请输入6位长度的旧密码。'
                            }
                        ]
                    },
                    newPassword: {
                        identifier: 'newPassword',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入新密码。'
                            },
                            {
                                type: 'length[6]',
                                prompt: '请输入6位长度的新密码。'
                            }
                        ]
                    }
                }
            })
        ;
        $('form').submit(function () {
            var newPassword = $('input[name=newPassword]').val();
            var confirmPassword = $('input[name=confirmPassword]').val();
            if (newPassword !== confirmPassword) {
                $('form').form("add errors", ['两次密码输入不一致。']);
                return false;
            }
        });
    });
</script>
</body>
</html>
